package Hot100;

public class moveZeroes {
    public static void main(String[] args) {
        int nums[] = {1,0};
        moveZeroes(nums);
        for (int i = 0; i < nums.length; i++) {
            System.out.println(nums[i]);
        }
    }

    public static void moveZeroes(int[] nums) {
        int slow = 0;
        int fast = 0;
        while (fast < nums.length){
            while(nums[slow] != 0 && slow < nums.length - 1){
                slow++;
            }
            if(slow < nums.length - 1)
                fast = slow + 1;
            else
                fast = slow;
            while (nums[fast] == 0 && fast < nums.length - 1){
                fast++;
            }

            int temp = nums[slow];
            nums[slow] = nums[fast];
            nums[fast] = temp;
            slow++;
            fast++;
        }
    }
}
